import { Pipe, PipeTransform } from '@angular/core';

@Pipe({//用来转换通知状态
  name: 'getSendType'
})
export class GetSendTypePipe implements PipeTransform {

  transform(value: string): string {
    let map = {
        TRADE_ORDER:"支付",  
        WITHDRAWAL:"转出",  
        DEPOSIT:"转入", 
        WITHDRAWAL_CASH:"提现"
    };
    return map[value];
  };
};

@Pipe({//用来显示余额
  name: 'isShowCoin'
})
export class IsShowCoin implements PipeTransform {

  transform(value: string): string {
    let text = value ? '隐藏' : '显示';
    return text;
  };
};

@Pipe({//用来计算手续费
  name: 'getCommission'
})
export class GetCommission implements PipeTransform {

  transform(value: number, coin:any): string {
    let text ;
   if(value){
    var fee = 0
    if ((value * coin.userWithdrawalCashFeePercent) < coin.userWithdrawalCashFeeMin) {
      fee = 0.02
    } else {
      fee = value * coin.userWithdrawalCashFeePercent
    }
    text = fee
   }else{
    text =0;
   }
    return text;
  };
};

@Pipe({//列表内狀態的翻譯
  name: 'getListKeyType'
})
export class GetListKeyType implements PipeTransform {

  transform(value: string): string {
    let text = value;
    let map ={
      TRADE_ORDER:"支付", 
      SCAN_PAY:"扫码支付", 
      AUTH_PAY:"条形码支付", 
      WAP_PAY:"网站支付", 
       
      SUCCESS :"成功",  
      WITHDRAWAL:"转出",  
      WAITING_PAYMENT:"等待付款",  
      WITHDRAWAL_CASH:"提现",
      DEPOSIT:"转入", 
      PENDING:'待审核',
      CANCEL_TRANSFER:'取消(平台发起)',
      APPROVAL: '待转账',
      COMPLETED: '完成',
      FAILED: '失败',
      REJECTED: '拒绝',
      CANCELED: '取消(用户发起)'
    } ;
    if(map[value]){
      text = map[value];
    };
    return text;
  };
};
